<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="./XTimer.js"></script>
</head>
<body>
<div id="t"></div>

<button type="button" onclick="stopTimer()">停止计时</button>

<script>
var timer = new XTimer();
timer.setStaticTime(1547028890000 /*, 服务器当前时间 可选*/);
timer.onTick = function() {
    var m = timer.minutes < 10 ? '0' + timer.minutes : timer.minutes;
    var s = timer.seconds < 10 ? '0' + timer.seconds : timer.seconds;
    
    document.getElementById('t').innerHTML = m + ':' + s;
    console.log(timer.minutes + ':' + timer.seconds);
};
timer.onEnd = function() {
    console.log('end')
};
timer.tick();


function stopTimer() {
    timer.stop();
}
</script>
</body>
</html>
